<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	<style>
		.parent{
			background: red;
			height: 50px;




		}
		.child{
			margin:0 auto;
		    width: 50px;
		    height: 100%;
		    background:yellow;
		    text-align: center; 
		}
	</style>	
</head>
<body>
	<div class="parent">
		<div class="child">居中</div>
	</div>
</body>
</html>